﻿using UnityEngine;

namespace UnityMovementAI
{
    [RequireComponent(typeof(Pursue))]
    public class PursueUnit : MonoBehaviour
    {


        public MovementAIRigidbody target;

        SteeringBasics steeringBasics;
        Pursue pursue;


        [Header("运行时")]
        public bool bIsActive = true;
        void Start()
        {
            steeringBasics = GetComponent<SteeringBasics>();
            pursue = GetComponent<Pursue>();
        }

        void FixedUpdate()
        {
            if (!bIsActive) return;
            if (target==null){Debug.Log("Pursue Target Not Set"); return;}
            Vector3 accel = pursue.GetSteering(target);

            steeringBasics.Steer(accel);
            steeringBasics.LookWhereYoureGoing();
        }
        public void SetActive(bool x){
            bIsActive = x;
        }
    }
}